#include <Video.h>

Video::Video() : QWidget()
{
	setFixedSize(320, 240);
	img = new QLabel(this);
	img->setPixmap(QPixmap("images/img.jpg"));

	rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
}


void Video::mousePressEvent(QMouseEvent *event)
{
	origin = event->pos();
	if (!rubberBand)
		rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
	rubberBand->setGeometry(QRect(origin, QSize()));
	rubberBand->show();
}

void Video::mouseMoveEvent(QMouseEvent *event)
{
	rubberBand->setGeometry(QRect(origin, event->pos()).normalized());
}

void Video::mouseReleaseEvent(QMouseEvent *event)
{
	rubberBand->hide();
	end = event->pos();
}

void Video::setImg(unsigned char * buff, int width, int height)
{
	img->setPixmap(QPixmap::fromImage(QImage(buff, width, height, QImage::Format_RGB888)));
}
